package com.scqkxx.gamebox.activity.group;

import android.content.ContentValues;
import android.support.v7.widget.LinearLayoutManager;
import android.util.Log;

import com.avos.avoscloud.AVException;
import com.avos.avoscloud.AVObject;
import com.avos.avoscloud.AVQuery;
import com.avos.avoscloud.FindCallback;
import com.scqkxx.gamebox.R;
import com.scqkxx.gamebox.activity.activities.utils.ActivityUtil;
import com.scqkxx.gamebox.activity.group.adapter.GroupMemberAdapter;
import com.scqkxx.gamebox.activity.group.adapter.GroupTransferAdapter;
import com.scqkxx.gamebox.databinding.ActivityGroupEditBinding;
import com.scqkxx.gamebox.databinding.ActivityGroupTransferBinding;
import com.scqkzqtz.base.base.BaseActivity;

import java.util.ArrayList;
import java.util.List;

public class GroupTransferActivity extends BaseActivity<ActivityGroupTransferBinding> {

    private GroupTransferAdapter groupTransferAdapter;
    private List<AVObject> dataList = new ArrayList<>();

    @Override
    public int setLayoutId() {
        return R.layout.activity_group_transfer;
    }

    @Override
    public void init() {
        binding.titleView.setOnTitleClickListener(mTitleType -> finish());

        groupTransferAdapter = new GroupTransferAdapter(R.layout.item_group_transfer, dataList);
        binding.rvGroupMembers.setLayoutManager(new LinearLayoutManager(this));
        binding.rvGroupMembers.setAdapter(groupTransferAdapter);

        String groupId = getIntent().getStringExtra("groupId");
        ContentValues contentValues = new ContentValues();
        contentValues.put("groupId",groupId);

        AVQuery<AVObject> query = AVQuery.getQuery("GroupUser");
        query.whereEqualTo("groupId",Integer.parseInt(groupId));
        query.findInBackground(new FindCallback<AVObject>() {
            @Override
            public void done(List<AVObject> avObjects, AVException e) {
                Log.i("GroupUser",avObjects+"");
                if (e == null && avObjects != null && avObjects.size() > 0) {
                    dataList.clear();
                    dataList.addAll(avObjects);
                    groupTransferAdapter.setNewData(dataList);
                }
            }
        });

    }
}
